#include "stdafx.h"
#include "memorygame.h"
#include "qgraphicsitemtopic.h"

QBrush QGraphicsItemTopic::m_backroundBrush( QColor( 100, 170, 150 ) );
QFont QGraphicsItemTopic::m_font( "Arial", 20, QFont::StyleItalic );

QGraphicsItemTopic::QGraphicsItemTopic( int x, int y, int width, int height, MemoryGame & parent, const QString & topicName )
:   QGraphicsRectItem( x, y, width, height ),
    m_topicName( topicName ),
    m_parent( parent )
{

}

QGraphicsItemTopic::~QGraphicsItemTopic()
{

}

void QGraphicsItemTopic::paint( QPainter * painter, const QStyleOptionGraphicsItem * option, QWidget * widget )
{
    QRectF r( rect() );
    painter->setBrush( m_backroundBrush );
    painter->drawRect( r );
    painter->setFont( m_font );
    QFontMetrics fontMetrics( m_font );
    painter->drawText( r, Qt::AlignCenter, m_topicName );
}